package com.styytech.dadabao.api.requestresult;

import com.styytech.dadabao.api.response.AbstractResponseResult;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by User on 2015/8/3.
 */
public class BankCardResult extends RequestResult {
    /**
     * 构造函数
     *
     * @param httpResponseResult
     */
    public BankCardResult(AbstractResponseResult httpResponseResult) {
        super(httpResponseResult);
    }

    @Override
    public void doBusiness() {
        super.doBusiness();
        if (super.isSuccess()) {
            dataParse((JSONArray) super.getRows());
        }
    }

    private void dataParse(JSONArray jsonArray) {
        String bankName = null;
        if (jsonArray != null && !jsonArray.isNull(0)) {
            try {
                JSONObject json = jsonArray.getJSONObject(0);
                bankName = json.has("bankName") ? json.getString("bankName") : null;
            } catch (JSONException e) {
                e.printStackTrace();
            }

        }
        httpResponseResult.executeSuccess(bankName);
    }
}
